package com.googlecode.etrade.client.acaotab;

import com.extjs.gxt.ui.client.Style.LayoutRegion;
import com.extjs.gxt.ui.client.util.Margins;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.extjs.gxt.ui.client.widget.layout.BorderLayout;
import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData;

/**
 * A classe AcoesTab configura a aba de visualiza&ccedil;&atilde;o de
 * a&ccedil;&otilde;es.
 * 
 * @author Rafael Freitas
 * 
 */

public class AcoesTab extends LayoutContainer {

	private ContentPanel gridPanel;
	private FormPanel formPanel;
	private ContentPanel chartPanel;

	public AcoesTab() {
		buildAcoesTab();
		GridAcoes gridAcoes = new GridAcoes();
		gridPanel.add(gridAcoes);
	}

	private void buildAcoesTab() {
		// configura os paineis
		LayoutContainer inner = new LayoutContainer();
		gridPanel = new ContentPanel();
		gridPanel.setHeading("Lista de Ações");
		formPanel = new FormPanel();
		formPanel.setHeading("Detalhes da Ação Selecionada");
		chartPanel = new ContentPanel();
		chartPanel.setHeading("Gráfico da Ação Selecionada");

		// configura o layout direito
		BorderLayoutData inNorth = new BorderLayoutData(LayoutRegion.NORTH, 320);
		inNorth.setMinSize(320);
		inNorth.setMaxSize(600);
		inNorth.setSplit(true);
		BorderLayoutData inCenter = new BorderLayoutData(LayoutRegion.CENTER);
		inCenter.setMargins(new Margins(5, 0, 0, 0));
		inner.setLayout(new BorderLayout());
		inner.add(formPanel, inNorth);
		inner.add(chartPanel, inCenter);

		// configura o centro
		BorderLayoutData outCenter = new BorderLayoutData(LayoutRegion.CENTER);
		outCenter.setMargins(new Margins(5));
		BorderLayoutData east = new BorderLayoutData(LayoutRegion.EAST, 400);
		east.setMinSize(400);
		east.setMaxSize(600);
		east.setSplit(true);
		east.setMargins(new Margins(5, 5, 5, 0));
		setLayout(new BorderLayout());
		add(gridPanel, outCenter);
		add(inner, east);
	}
}
